<?php

$oDb =& Database::get();
$oTpl =& App::getTemplate();

$aItems = $oDb->getRows("SELECT optionid, languageid, varid, varname, text FROM ". App::getT('language_options') ." ORDER BY optionid DESC");
$aRemove = array();
$aFinalRemoval = array();
foreach($aItems as $aItem)
{
	$aOptions = $oDb->getRows("SELECT * 
		FROM ". App::getT('language_options') ." 
		WHERE ".
			"`languageid` = ".$aItem['languageid']." AND varname = '". $aItem['varname'] ."' AND text = '". $oDb->escape($aItem['text'])."'".
			" ORDER BY optionid");
	
	if(count($aOptions)>1)
	{
		
		for($i=1;$i<count($aOptions);++$i)
		{
			$aFinalRemoval[] = $aOptions[$i];
			$oDb->_delete(App::getT('language_options'), "optionid = '". $aOptions[$i]['optionid'] ."'");
		}
	}
}

$oTpl->assign(array
(
	'aItems' => $aFinalRemoval,
));

?>